package com.edu.networkexperimentation.model.response;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import com.edu.networkexperimentation.model.domain.Process;

@Data
public class ResponseAlgorithmTableData {
    private List<Double> maxFitness;
    private List<Double> averageFitness;
    private List<Double> c_maxFitness;
    private List<Double> c_averageFitness;
    private List<Double> allFitness;
    public ResponseAlgorithmTableData(Process r_process, Process g_process, Process c_g_process) {
        String[] allFitness_str = r_process.getMaxfitness().split(",");
        String[] maxFitness_str = g_process.getMaxfitness().split(",");
        String[] averageFitness_str = g_process.getAveragefitness().split(",");
        String[] c_maxFitness_str = c_g_process.getMaxfitness().split(",");
        String[] c_averageFitness_str = c_g_process.getAveragefitness().split(",");
        maxFitness = new ArrayList<Double>();
        averageFitness = new ArrayList<>();
        c_maxFitness = new ArrayList<>();
        c_averageFitness = new ArrayList<>();
        allFitness = new ArrayList<>();
        for (String s : allFitness_str) {
            allFitness.add(Double.valueOf(s));
        }
        for (String s : maxFitness_str) {
            maxFitness.add(Double.valueOf(s));
        }
        for (String s : averageFitness_str) {
            averageFitness.add(Double.valueOf(s));
        }
        for (String s : c_maxFitness_str) {
            c_maxFitness.add(Double.valueOf(s));
        }
        for (String s : c_averageFitness_str) {
            c_averageFitness.add(Double.valueOf(s));
        }
    }
}
